<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="default" />
<title>Insert title here</title>

<script type="text/javascript">
	$(document).ready(
			function() {

				$("#yincang").hide();//div隐藏
				$("#yincang2").hide();//div隐藏

				var tab = document.getElementById("contentTable");

				//表格行数
				var rows = tab.rows.length;
				//表格列数
				var cells = tab.rows.item(0).cells.length;

				if(rows > 1){// 不要第一行的 thead)
				for ( var i = 1; i < rows; i++) {
				 var totalWork=	$("#contentTable tr:eq("+i+") td:eq(1)").text();
				var accomplish=$("#contentTable tr:eq("+i+") td:eq(2)").text();
				var completeness = Math.round(accomplish / totalWork * 10000)
				/ 100.00 + "%";
					$("#contentTable tr:eq("+i+") td:eq(3)").html(completeness);
				}
	
				}
			});

	//二级联动查询用户
	/* function ajaxdept() {
		$("#user option:not(:first)").remove();
		$("#user").val("-1");
		var deptId = $("#dept").val();
		if (deptId == "" || deptId == null) {
			$("#s2id_user").find("a:first").find("span:first").html("请选择");
			return false;
		} else {
			$.ajax({
				type : "post",
				url : "${ctx}/crm/project/project/findUser",
				data : "deptId=" + deptId,
				success : function(data) {
					for ( var i = 0; i < data.length; i++) {
						$("#user").append(
								"<option value='"+data[i].id+"'>"
										+ data[i].name + "</option>");
					}
				}
			});
			$("#user option:first").prop("selected", 'selected');
			$("#s2id_user").find("a:first").find("span:first").html("请选择");
		}
	} */

	function tanchu(elem) {
		$("#yincang").show();
		$(".shade").show();
		var workloadId = $(elem).parent().parent().find("td:first").find(
				"input").val();
		$("#hiddnInput").val(workloadId);

	}

	function tanchu2(elem) {
		$("#yincang2").show();
		$(".shade").show();

		var workloadId = $(elem).parent().parent().find("td:first").find(
				"input").val();
		$("#hiddnInput2").val(workloadId);
	}

	function change() {
		$("#yincang").hide();
		$(".shade").hide();
	}

	function change2() {
		$("#yincang2").hide();
		$(".shade").hide();
	}
	
</script>

<style type="text/css">
#yincang {
	position: fixed;
	width: 80%;
	height: 80%;
	top: 10%;
	left: 10%;
}

#yincang2 {
	position: fixed;
	width: 80%;
	height: 80%;
	top: 10%;
	left: 10%;
}

.shade {
	display: none;
	width: 100%;
	height: 100%;
	background: black;
	position: fixed;
	z-index: 998;
	opacity: 0 .5;
	filter: alpha(opacity =     50);
	/* ie 有效*/
	-moz-opacity: 0.5; /* Firefox  有效*/
	opacity: 0.5;
	width: 100%;
	filter: alpha(opacity =     50); /* 通用，其他浏览器  有效*/
}

.yincang {
	z-index: 999;
}
</style>
</head>
<body>

	<c:if test="${message=='删减的值不正确'}">
		<div class="alert alert-success">删减的值不正确</div>
	</c:if>

	<div class="shade"></div>
	<ul class="nav nav-tabs">
		<li class="active">
			<a href="javascript:void(0)">工作量分配</a>
		</li>
	</ul>

	<div>
		<form action="${ctx}/crm/mission/mission/workAllocation" method="post" style="display: inline;" class="form-search">
			<ul class="ul-form">
				<%-- <li>
					<label>部门</label>
					<select class="input-xlarge" id="dept" name="dept" style="width: 150px;" onchange="ajaxdept()">
						<option value="">请选择</option>
						<c:forEach items="${dept}" var="dept">
							<option value="${dept.id}">${dept.name}</option>
						</c:forEach>
					</select>
				</li> --%>
				<li>
					<label>员工</label>
					<select id="user" class="user" name="user" style="width: 150px;">
						<c:forEach items="${staffList}" var="staffList">
							<option value="${staffList.staffId}">${staffList.staffName}</option>
						</c:forEach>
					</select>
				</li>
				<li>
					<label>工作量</label>
					<input type="number" name="num" min="1" value="1"/>
				</li>
				<li class="btns">
					<input id="btnSubmit" class="btn btn-primary" type="submit" value="分配" />
				</li>
			</ul>
		</form>

	</div>
	<br />
	<div>
		<table id="contentTable" style="table-layout: fixed;" class="table table-striped table-bordered table-condensed" border="1">
			<thead>
				<tr>
					<th>部员</th>
					<th>当月计划工作量</th>
					<th>当月实际工作量</th>
					<th>本月完成率</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${workloadList}" var="workloadList">
					<tr>

						<td>
						
						<a id="quantity" href="${ctx}/crm/mission/mission/WorkLoadSelect?dividerId=${workloadList.divider}">${workloadList.dividerName}</a>
						<input type="hidden" id="hiddenId" value="${workloadList.id}"><!-- 隐藏值 -->	
						</td>
						<td>
							<span class="totalWork">${workloadList.totalWork}</span>
						</td>
						<td>
							<span class="accomplish"> ${workloadList.accomplish}</span>
						</td>
						<td>
							<span class="completeness">${workloadList.accomplish/workloadList.totalWork}</span>
						</td>
						<td>
							<a id="cuname" href="#" onclick="tanchu(this)">追加</a>

							<a id="cuname" href="#" onclick="tanchu2(this)">删减</a>
                      
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>

	<div id="yincang" class="yincang" align="center">
		<div style="width: 30%; background: #C3C3C3;" align="right">
			<a href="javascript:void(0)" onclick="change()">
				<img style="background: red;" width="25px" src="${ctxStatic}/businessImg/exit.png">
			</a>
		</div>
		<div style="width: 30%; background: #DFC6BF; height: 30%">
			<br />
			<br />
			<form action="${ctx}/crm/mission/mission/superadditionWorkLoad" method="post">
				<table>
					<tr>
						<td>追加工作量</td>
						<td></td>
					</tr>
					<tr>
						<td>
							<input type="hidden" name="hiddnInputid" id="hiddnInput" />
							<input type="text" name="addnumb">
						</td>
						<td>
							<input type="submit" value="确认追加">
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>


	<div id="yincang2" class="yincang" align="center">
		<div style="width: 30%; background: #C3C3C3;" align="right">
			<a href="javascript:void(0)" onclick="change2()">
				<img style="background: red;" width="25px" src="${ctxStatic}/businessImg/exit.png">
			</a>
		</div>
		<div style="width: 30%; background: #DFC6BF; height: 30%">
			<br />
			<br />
			<form action="${ctx}/crm/mission/mission/cutWorkLoad" method="post">
				<table>
					<tr>
						<td>删减工作量</td>
						<td></td>
					</tr>
					<tr>
						<td>
							<input type="hidden" name="hiddnInputid2" id="hiddnInput2" />
							<input type="text" name="cutnumb">
						</td>
						<td>
							<input type="submit" value="确认删减">
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>